
# Reference: <https://postmarketos.org/devicepkg>
# Maintainer: Alexander Martinz <amartinz@shiftphones.com>

pkgname=device-shift-axolotl
pkgdesc="SHIFT6mq"
pkgver=15
pkgrel=2
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="
	linux-postmarketos-qcom-sdm845
	make-dynpart-mappings
	mkbootimg
	postmarketos-base
	soc-qcom-sdm845
	soc-qcom-sdm845-ucm
	soc-qcom-sdm845-qbootctl
	fwupd>=1.8.6
"
makedepends="devicepkg-dev postmarketos-test"
source="
	deviceinfo
	hexagonrpcd.confd
	modules-initfs
	q6voiced.conf
	81-libssc-shift-axolotl.rules
"
subpackages="
	$pkgname-nonfree-firmware:nonfree_firmware
	$pkgname-nonfree-firmware-openrc:nonfree_firmware_openrc
	$pkgname-pmtest
"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname
}

nonfree_firmware() {
	pkgdesc="Modem, GPU and WiFi Firmware, also needed for osk-sdl"
	depends="
		firmware-shift-sdm845>=20230815-r2
		hexagonrpcd
		soc-qcom-sdm845-nonfree-firmware
		soc-qcom-sdm845-modem
	"

	install -Dm644 "$srcdir"/81-libssc-shift-axolotl.rules -t "$subpkgdir"/usr/lib/udev/rules.d/
	install -Dm644 q6voiced.conf "$subpkgdir"/etc/conf.d/q6voiced
}

nonfree_firmware_openrc() {
	install_if="$pkgname-nonfree-firmware=$pkgver-r$pkgrel openrc"
	replaces="hexagonrpcd-openrc"
	install="$subpkgname.post-install $subpkgname.post-upgrade"

	install -Dm644 "$srcdir"/hexagonrpcd.confd "$subpkgdir"/etc/conf.d/hexagonrpcd-sdsp
}

pmtest() {
	depends="bootrr qrtr firmware-shift-sdm845 unl0kr"
	install_if="$pkgname=$pkgver-r$pkgrel postmarketos-mkinitfs-hook-ci"
	install="$subpkgname.post-install"

	devicepkg_pmtest_post_install "ttyMSM0,115200" > "$subpkgname.post-install"
}

sha512sums="
e3f8a8d556a3c3134791693f2003aa64465b6971f7e353f547d6f1cbe3a0a0225a225e40ee4dbed951c0fa67f5a4636fd15953f6a3fe23d4f098fa1d39baa8f5  deviceinfo
5966325963a3a62c919b5f39f7bc56e1785f192f50c40a6cc644a2fea0c9b8dd083e287ef43c59c2b9cab5c88d65266b0cd9cf1f5110924950bd250be5385622  hexagonrpcd.confd
4dc84207c5ca84b33b74139c8b0c9ce5baa8bcb1068df9943c478c02abcf8daccb88e06af63f120a434a115e277008e899305bd5239d8669436cb269889040e9  modules-initfs
2a3cbdad5aa91181d24a4e56e63986af6accf887c64fa4d1b6ddad1926e29050243c4b1e2fd892d38ca7c16e24dff8545a16552e5749ae31b6d01bf428468e51  q6voiced.conf
3bd3a82b88a7aca4e2df2f5522cee7a98d017994f1dc1a965a7e386be9c17632b9cdbe013feb737dec12e99d74f54a9e4599144193bb57ec18e6d6a18c94cf1f  81-libssc-shift-axolotl.rules
"
